/**
 * Created by zhourh on 2018/6/14.
 */
public class DetectCapital {

    public static void main(String[] args)  {
        System.out.println(new DetectCapital().detectCapitalUse("USA"));
        System.out.println(new DetectCapital().detectCapitalUse("leetcode"));
        System.out.println(new DetectCapital().detectCapitalUse("Google"));
        System.out.println(new DetectCapital().detectCapitalUse("FlaG"));
    }

    public boolean detectCapitalUse(String word) {
        if (word == null) {
            return false;
        }

        if (word.length() <= 1 || word.substring(1).toLowerCase().equals(word.substring(1))) {
            // 除首字母外全部小写
            return true;
        }

        if (word.toUpperCase().equals(word)) {
            // 全部大写字母
            return true;
        }

        return false;
    }
}
